package com.wc.AlgoOJ_homework.AlgoOJ_BL4.E_整数删除;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.PriorityQueue;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/4/6 9:28
 * @description http://43.138.190.70:8888/p/1130?tid=660a4f84d7ba43eb2f4c549d
 */
public class Main {
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 500010;
    static int[] l = new int[N];
    static int[] r = new int[N];
    static long[] a = new long[N];
    static boolean[] st = new boolean[N];
    static long[] add = new long[N];

    static PriorityQueue<Pair> q = new PriorityQueue<>();
    static int n, k;

    public static void main(String[] args) {
        n = sc.nextInt();
        k = sc.nextInt();
        for (int i = 1; i <= n; i++) {
            l[i] = i - 1;
            r[i] = i + 1;
            q.add(new Pair(sc.nextLong(), i));
        }
        while (q.size() > n - k) {
            Pair t = q.poll();
            if (add[t.y] > 0) {
                t.x += add[t.y];
                add[t.y] = 0;
                q.add(t);
            } else {
                int li = l[t.y];
                int ri = r[t.y];
                add[li] += t.x;
                add[ri] += t.x;
                l[ri] = li;
                r[li] = ri;
                st[t.y] = true;
            }
        }
        while (!q.isEmpty()) {
            Pair t = q.poll();
            a[t.y] = t.x + add[t.y];
        }
        for (int i = 1; i <= n; i++) {
            if (!st[i]) out.print(a[i] + " ");
        }
        out.flush();
    }

    static class Pair implements Comparable<Pair> {
        long x;
        int y;

        Pair(long x, int y) {
            this.x = x;
            this.y = y;
        }

        @Override
        public int compareTo(Pair o) {
            if (x == o.x) {
                return y - o.y;
            }
            return Long.compare(x, o.x);
        }
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}
